package bursy.finance.common;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * This is basic logger class.
 * As of now, it is a mock utilizing System.out and using static methods.
 * TODO: make a correct logger factory (with source of log) use existing solution.
 * @author alex
 */
public class Logger {
    private enum Severity {
        INFO,
        WARN,
        ERROR
    }

    private static SimpleDateFormat sdf = new SimpleDateFormat("[HH:mm:ss]");
    
    private static void putMessage(String message, Severity severity) {
        StringBuilder messageBuilder = new StringBuilder();
        messageBuilder.append(sdf.format(new Date()));
        messageBuilder.append(" ");
        messageBuilder.append(severity.toString());
        messageBuilder.append(" ");
        messageBuilder.append(message);
        System.out.println(messageBuilder);
    }
    
    public static void info(String message) {
        putMessage(message, Severity.INFO);
    }
    
    public static void warn(String message) {
        putMessage(message, Severity.WARN);
    }
    
    public static void error(String message) {
        putMessage(message, Severity.ERROR);
    }
    
    public static void error(String message, Exception e) {
        // TODO: does it even work?
        putMessage(message + e, Severity.ERROR);
    }
}
